#include "BitPointer.h"


BitPointer::BitPointer()
{
	pointer = 0;
	bitNumber = 0;
}

BitPointer::BitPointer(volatile unsigned char* p, unsigned char number)
{
	pointer = (unsigned char*) p;
	bitNumber = number;
	
}


BitPointer::BitPointer(unsigned char* p, unsigned char number)
{
	pointer =  p;
	bitNumber = number;
}
void BitPointer::setBit(unsigned char value)
{
	//Should do an assertion here to check if value is not 1 or 0.
	*pointer = SetBit(*pointer, bitNumber, value);	
}

unsigned char BitPointer::getBit()
{
	unsigned char* p = (unsigned char*) pointer;
	unsigned char value = GetBit(*p, bitNumber);
	return value;
}


void BitPointer::notBit()
{
	unsigned char* p = (unsigned char*) pointer;
	unsigned char val = (~(GetBit(*p, bitNumber)) & 0x01);
	*p = SetBit(*p, bitNumber, val); 
}


/*
bool BitPointer::operator==(void* p)
{
	if(p == (void*) pointer)
		return true;
	else
		return false;
}
bool BitPointer::operator==(BitPointer& p)
{
	if(pointer == p.pointer && bitNumber == p.bitNumber)
		return true;
	else
		return false;
}

*/
